<?php
	header("Content-type: image/png");
    // Set some test variables
    $font = "fonts/Frabk.TTF";
	
    $text = $_GET['text'];
	$text2 = $_GET['text2'];
    $size = $_GET['size'];
	$f_color = $_GET['color'];
	$f_color2 = $_GET['color2'];
    $angle = 0;

    // Create an image and fill the background with lightgray
    $image = imagecreatetruecolor(200, 40);
	
	$colorBg = imagecolorallocate($image, 66, 65, 73);
	
	//imagecolortransparent($image, $colorBg);
	
	//imagealphablending($image, false);
	//$color = imagecolorallocatealpha($image, 0, 0, 0, 127);
	
    imagefill($image, 0, 0, $colorBg);
	imagesavealpha($image, true);
	
	
    // Run a fixed version of imagettfbbox()
    $bbox = imagettfbbox_fixed($size, $angle, $font, $text);

    // Make some text and center the text on the image.
    // imagettftext() pivot is on lower left
    //imagettftext($image, $size, $angle, imagesx($image) / 2 - $bbox['width'] / 2, imagesy($image) / 2 + $bbox['height'] / 2, hexdec("F8AD02"), $font, $text);
	imagettftext($image, $size, $angle, 0, imagesy($image) / 2 + $bbox['height'] / 2, hexdec($f_color), $font, $text);
	imagettftext($image, $size, $angle, $bbox['width'], imagesy($image) / 2 + $bbox['height'] / 2, hexdec($f_color2), $font, $addon.' '.$text2);
    // Show the image
    imagepng($image);

    function imagettfbbox_fixed($size, $angle, $font, $text)
    {
        // Get the boundingbox from imagettfbbox(), which is correct when angle is 0
        $bbox = imagettfbbox($size, 0, $font, $text);

        // Rotate the boundingbox
        $angle = pi() * 2 - $angle * pi() * 2 / 360;
        for ($i=0; $i<4; $i++)
        {
            $x = $bbox[$i * 2];
            $y = $bbox[$i * 2 + 1];
            $bbox[$i * 2] = cos($angle) * $x - sin($angle) * $y;
            $bbox[$i * 2 + 1] = sin($angle) * $x + cos($angle) * $y;
        }

        // Variables which tells the correct width and height
        $bbox['width'] = $bbox[0] + $bbox[4];
        $bbox['height'] = $bbox[1] - $bbox[5];

        return $bbox;
    }
?>